package cn.cnsy123.shorturls.business.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;

import cn.cnsy123.shorturls.api.controller.param.SysSqlExecuteLogInsertParam;
import cn.cnsy123.shorturls.business.event.SysSqlExecuteLogEvent;
import cn.cnsy123.shorturls.business.service.SysSqlExecuteLogService;

public class SqlExecuteLogEventListener implements ApplicationListener<SysSqlExecuteLogEvent> {

    @Autowired
    private SysSqlExecuteLogService sysSqlExecuteLogService;
    
    @Override
    public void onApplicationEvent(SysSqlExecuteLogEvent event) {
        SysSqlExecuteLogInsertParam sysSqlExecuteLogInsertParam = (SysSqlExecuteLogInsertParam)event.getSource();
        if(sysSqlExecuteLogInsertParam != null) {
            sysSqlExecuteLogService.saveSqlExecutorLog(sysSqlExecuteLogInsertParam);
        }
    }

}
